package com.benjaminwan.read.free.utils

import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import com.benjaminwan.read.free.R
import java.io.File

/**
 * 获取fileProvider
 *
 * @return String
 **/
val Context.fileProvider: String
    get() = this.packageName + ".provider"
val Fragment.fileProvider: String
    get() = requireContext().fileProvider

fun Context.shareFile(path: String) {
    val intent = this.getSendIntent(File(path), fileProvider)
    startActivity(
        Intent.createChooser(
            intent,
            getString(R.string.dialog_share_title)
        )
    )
}